meson build: only build docs if we can run required objects in build environment
authorJohn Marshall <jtm.home@gmail.com>
Mon, 11 Jun 2018 09:12:24 +0000 (10:12 +0100)
committerØyvind Kolås <pippin@gimp.org>
Sat, 25 May 2019 16:13:31 +0000 (18:13 +0200)
docs/meson.build
meson.build

index 03a38c9c605de8ce02c5c29dd971ad2fd731a36c..11d517e065ceb92e688aba2bbba012ea0e52e897 100644 (file)
@@ -17,12 +17,16 @@ babl_css = configure_file(input : 'babl.css',
   output : 'babl.css',
   configuration : configuration_data())
 
+index_html_tmp_env = [
+  'BABL_PATH='+ join_paths(meson.build_root(), 'extensions'),
+]
+
 index_html_tmp = custom_target('index.html.tmp',
   input : [ babl_html_dump, ],
   output: [ 'index.html.tmp', ],
   command: [
     env_bin,
-    'BABL_PATH='+ join_paths(meson.build_root(), 'extensions'),
+    index_html_tmp_env,
     babl_html_dump
   ],
   capture: true,
index eb999b36ecfa13165e9ed3104d9c25fefc2b481f..142a203d5471ac525945dc7ab91731860d3583b5 100644 (file)
@@ -145,6 +145,8 @@ build_platform_win32 = (build_os.startswith('mingw') or
                         build_os.startswith('cygwin') or
                         build_os.startswith('windows'))
 
+# Only run cross compile objects if we have exe wrapper
+cc_can_run = not meson.is_cross_build() or meson.has_exe_wrapper()
 
 ################################################################################
 # Compiler arguments
@@ -307,13 +309,26 @@ endif
 ################################################################################
 # Build utilities
 
-env_bin = find_program('env', required: true, native: true)
+env_bin = find_program('env', required: false, native: true)
 git_bin = find_program('git', required: false, native: true)
 rsvg_convert_bin = find_program('rsvg-convert', required: false,
   native: true)
 test_bin = find_program('test', required: false, native: true)
 w3m_bin = find_program('w3m', required: false, native: true)
 
+################################################################################
+# Build flags
+
+build_docs = false
+
+if get_option('with-docs')
+  if cc_can_run and env_bin.found() and not build_platform_win32
+    build_docs = true
+  else
+    warning('Unable to generate docs in this environment')
+  endif
+endif
+
 
 ################################################################################
 # Configuration files
@@ -350,12 +365,11 @@ subdir('babl')
 subdir('extensions')
 subdir('tests')
 subdir('tools')
-if get_option('with-docs')
+if build_docs
   subdir('docs')
 endif
 
-
-if w3m_bin.found()
+if w3m_bin.found() and build_docs
   custom_target('README',
     input : [ join_paths('docs', 'index.html'), ] ,
     output: [ 'README' ] ,